package com.ityu.cloudclientone.controller;

import com.ityu.cloudclientone.feign.ApiClient;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * author: yu.jl
 * e-mail: bbfx89625@gmail.com
 * time  : 2021/6/25
 * desc  :
 */
@RestController
@Slf4j
@RefreshScope
class CloudClientOneController {




    final ApiClient apiClient;

    @Value("${app-name}")
    String name;

    CloudClientOneController( ApiClient apiClient) {
        this.apiClient = apiClient;
    }


    @ApiOperation(value = "测试服务1")
    @GetMapping(value = "/testClientOne")
    public String testClientOne() {
        return "我是服务一的无参接口";
    }

    @ApiOperation(value = "测试服务1")
    @GetMapping(value = "/testClientTwo/{name}/{content}")
    public String testClientTwo(@PathVariable String name, @PathVariable String content) {
        log.info("{}输入的内容为{}", name, content);
        return "我是服务一的有参接口" + name + content;
    }

    @ApiOperation(value = "测试调用")
    @GetMapping(value = "/testClientThree/{name}/{content}")
    public String testClientThree(@PathVariable String name, @PathVariable String content) {
        String s = apiClient.testServerTwo(name, content);
        return s;
    }

    @ApiOperation(value = "测试异常调用")
    @GetMapping(value = "/testError")
    public String testError() {
        String s = apiClient.testError();
        return s;
    }

    @ApiOperation(value = "测试异常调用2")
    @GetMapping(value = "/testError2")
    public String testError2() {
        String s = apiClient.testError2();
        return s;
    }

    @ApiOperation(value = "测试配置")
    @GetMapping(value = "/testConfig")
    public String testConfig() {
        return name;
    }


}
